package com.source.multithread.run;

import javafx.scene.paint.Stop;

/**
 * @Author wengqy
 * @Date 2020/12/19
 */
public class StopThread  implements Runnable{
    private  boolean  flag = true;


    public static void main(String[] args) {
        StopThread  stopThread  = new StopThread();
        new Thread(stopThread,"AA").start();
        new Thread(stopThread,"BB").start();
        for (int i = 0; i <100 ; i++) {
            System.out.println("main"+i);
            if(i==90){
                stopThread.stop();
            }

        }
    }

    private void stop() {
        this.flag =false;
    }


    @Override
    public void run() {
        while(flag){
            int i=0;
            System.out.println(Thread.currentThread().getName()+"----"+i++);
        }
    }
}
